package com.boot.demo.config;

import com.luhui.source.PrefixCustomPropertySource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

/**
 * @author:Luhui
 * @qq:729913162
 * @Date:2018/11/3 0003
 * @Time:17:50
 */
@Component
public class MyPropertySource extends PrefixCustomPropertySource<String> {

    @Autowired
    private JdbcTemplate jdbcTemplate;
    public MyPropertySource(@Value("myConfig") String name) {
        super(name);
    }

    @Override
    protected String getPropertyPrefix() {
        return "myConfig";
    }

    @Override
    protected Object getCustomProperty(String name) {
        return jdbcTemplate.queryForList("select id from test").get(0).get("id");
    }
}
